import pickle

data = {"name": "张三", "age": 19, "address": "火星"}

# 序列化
with open("/tmp/foo.dat", "wb") as f:
    pickle.dump(data, file=f)
    print("序列化完成")

# 反序列化
with open("/tmp/foo.dat", "rb") as f:
    d = pickle.load(f)
    print("反序列化完成：", d)
